home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 640 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.9 KB

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: vandevod@cs.rpi.edu (David Vandevoorde)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: constant-expression extension
  5. Date: 2 Mar 1996 16:04:34 GMT
  6. Organization: RPI Computer Science
  7. Sender: vandevod@pleiades.cs.rpi.edu
  8. Approved: clamage@eng.sun.com (comp.std.c++)
  9. Message-ID: <xsoviknr24p.fsf@pleiades.cs.rpi.edu>
  10. References: <4h775a$m4s@ugress.uib.no>
  11. NNTP-Posting-Host: taumet.eng.sun.com
  12. Content-Type: text
  13. X-Nntp-Posting-Host: pleiades.cs.rpi.edu
  14. In-Reply-To: boukanov@afrodite.fi.uib.no's message of 01 Mar 1996 09:03:14 PST
  15. X-Newsreader: Gnus v5.1
  16. Content-Length: 934
  17. Originator: clamage@taumet
  18.  
  19. >>>>> "IB" == Igor Boukanov <boukanov@afrodite.fi.uib.no> writes:
  20. IB>    My proposal is to change definition of the "integral
  21. IB> constant-expression"[5.19] to something like this:
  22.  
  23. IB> An integral constant-expression is an expression that can be
  24. IB> calculated at the compilation phase.
  25.  
  26. IB> And according to this one would be able to use inline functions in
  27. IB> constant-expressions and instead of writing:
  28. [...]
  29.  
  30. This would imply that `inline' is no longer mere ``hint'', but in certain
  31. cases a requirement. Note that your proposed definition may either be
  32. hard to implement or imprecise.
  33.  
  34. E.g.,
  35.  
  36.     inline int fac(int k) {
  37.         int r = 1;
  38.         while (k) r *= k--;
  39.             return r;
  40.     }
  41.  
  42.     double d[fac(10)];    // ??
  43.  
  44. It's certainly feasible to compute this at compile-time... but this sort
  45. of requirement would make a compiler much more complex. (And it is not
  46. feasible, in general, to determine whether it is feasible :).
  47.  
  48.     Daveed
  49.  
  50.  
  51. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your
  52.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  53.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  54.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  55.   Comments? mailto:std-c++-request@ncar.ucar.edu
  56. ]
  57.